package cn.xfdzx.android.apps.shop.base;



/**
 * @author lfh
 * @date 2021/03/26
 * Description：  自动绑定对应的modec层
 */
public abstract class BasePresenterImp<V extends BaseView,M extends BaseModel> {
    protected V mView;
    protected M mModel;
    public abstract M createModel();
    /**
     * 绑定view，一般在初始化中调用该方法
     *
     * @param view view
     */
    public void attachView(V view) {
        this.mView = view;
        if (mModel == null){
            mModel = createModel();
        }
    }

    /**
     * 解除绑定view，一般在onDestroy中调用
     */

    public void detachView() {
        this.mView = null;
    }

    /**
     * View是否绑定
     *
     * @return
     */
    public boolean isViewAttached() {
        return mView != null;
    }


}
